﻿namespace ChessToys.ChessController
{
    using System;
    using System.Collections.Generic;
    using ChessToys;

    public class MovabilityBoardHeuristic : IBoardHeuristic
    {
        /// <inheritdoc />
        public double Heuristic(Board board)
        {
            int whiteMoveCount = MoveGeneratorUtils.PossibleMoves(board, Color.White).Count;
            int blackMoveCount = MoveGeneratorUtils.PossibleMoves(board, Color.Black).Count;
            if (whiteMoveCount == 0)
            {
                return 1;
            }
            if (blackMoveCount == 0)
            {
                return 0;
            }
            return ((double)blackMoveCount) / ((double)whiteMoveCount);
        }
    }
}
